<link type="text/css" rel="stylesheet" href="css/services.css"/>
 <style type="text/css">

.type1 {
    float: none;
}
 </style>
<div class="container type1">
		<h1>Danh mục</h1>

		<div id = "top_reserve">
			<div id = "content-right" style="float:right;">
			
			<div id = "add_new">
				<?php  
                    if( isset( $action )){
                        foreach($action as $a){
                            if( strtolower($a['id']) == 'new'){
                                echo anchor( base_url( ) . $a['url'], $a['label'] );
                                break;
                            }
                        }
                    } 
                        
                ?>
                            </div>
			</div>
		</div>


    <table id="">
	<tr>
	  <?php

                foreach ($rules as $i) {
					if (in_array($i['field_id'], $master_limited)) {
						if (isset($i['width']))
							$width = "width = '" . $i['width'] . "'";
						else
							$width = "";
						echo "<th $width class='".$i['class']."' style='".$i['style']."'>" . $i['html'] . "</th>";
					}
				}
            ?>
            <th class="last c">Action</th>
	</tr>
	 <?php
                for( $i = 0; $i < count( $results ); $i++ ){
					if($i%2==1) $odd="odd"; else $odd="";
                    echo "<tr class='$odd'>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	        
         			                
                                                                        if($item['control'] === "Integer"){
                                                                            echo '<td style="text-align: center;">';
                                                                            if($results[ $i ][ $item[ 'field_id' ] ] !== "0"){
                                                                                echo '<img alt="VIP" src="images/ok-icon.png" title="VIP"/>';
                                                                            }
                                                                            echo "</td>";
                                                                        }
                                                                        else
									if($item[ 'control' ] != "time"){
                                                                            echo "<td>";
										echo $results[ $i ][ $item[ 'field_id' ] ];
                                                                                echo "</td>";
                                                                        }
									else{
                                                                            echo '<td style="text-align: right;">';
                                                                            echo date("d/m/Y",$results[ $i ][ $item[ 'field_id' ] ]);
                                                                            echo "</td>";
                                                                        }					
    					}?>
                         
                        <?php 
                            }
                        echo "<td class='c'>";
                            if( isset( $action ) ){
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'edit'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'delete'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                            }
                      
                            if( isset( $custom_action ) ){
                                
                                foreach( $custom_action as $item ){
                                //    $a = explode( '=', $item );
                                //    if( isset( $a[ 0 ] ) )
                                        echo $results[$i][$item['action_name']]. "  ";
                                }
                            }
                        echo "</td>";
                    echo "</tr>";
                }
            ?>
        <?php
            if('' !== $this->pagination->create_links()){
                echo '<tr><td colspan="'. (count($rules) + 1) .'"><center><div class="pagination">'. $this->pagination->create_links().'</div></center></td></tr>';
            }
        ?>
        
	</table>

</div>